package T940;

public class Main {
}

class Solution {
    public static void main(String[] args) {
        System.out.println(distinctSubseqII("aba"));
    }

    public static int distinctSubseqII(String s) {
        int MOD = 1000000007;
        long sum = 1;
        long Last = 1;
        long[] dp = new long[26];
        for (int i = 0; i < s.length(); i++) {
            long sol = sum;
            sum = (Last * 2 - dp[s.charAt(i) - 'a'] + MOD) % MOD;
            Last = sum;
            dp[s.charAt(i) - 'a'] = sol;
        }
        return (int) ((sum + MOD - 1) % MOD);
    }
}